//
//  MineSetSwitchCell.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/11.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit

enum MineSetStyle{
    case switchButtonStyle
    case noRightIconStyle
    case rightAllStyle
}

class MineSetSwitchCell: UITableViewCell {
    var cellStyle:MineSetStyle?{
        didSet{
            switch self.cellStyle! {
            case .switchButtonStyle:
                self.contentView.addSubview(self.leftLabel)
                self.contentView.addSubview(self.switchButton)
                self.contentView.addSubview(self.showDowLabel)
                self.switchButton.center = CGPoint.init(x:(k_Wide - 16 - 17.5), y: 25)
                self.switchButton.onTintColor = UIColor.init(red: 7/255.0, green: 106/255.0, blue: 253/255.0, alpha: 1.0)
                self.leftLabel.snp.makeConstraints({ (make) in
                    make.left.equalTo(16)
                    make.right.equalTo(-16-35)
                    make.height.equalTo(15)
                    make.top.equalTo(17.5)
                })
                //            self.switchButton.snp.makeConstraints({ (make) in
                //                make.right.equalTo(-16)
                //                make.size.equalTo(CGSize.init(width: 35, height: 20))
                //                make.top.equalTo(15)
                //            })
                self.showDowLabel.snp.makeConstraints({ (make) in
                    make.left.equalTo(0)
                    make.right.equalTo(0)
                    make.bottom.equalTo(0)
                    make.height.equalTo(0.5)
                })
                
                break
            case .noRightIconStyle:
                self.contentView.addSubview(self.leftLabel)
                self.contentView.addSubview(self.rightLabel)
                self.contentView.addSubview(self.showDowLabel)
                self.leftLabel.snp.makeConstraints({ (make) in
                    make.left.equalTo(16)
                    make.width.equalTo(k_Wide/2 - 16)
                    make.height.equalTo(15)
                    make.top.equalTo(17.5)
                })
                self.rightLabel.snp.makeConstraints({ (make) in
                    make.right.equalTo(-16)
                    make.width.equalTo(k_Wide/2 - 16)
                    make.height.equalTo(15)
                    make.top.equalTo(17.5)
                })
                self.showDowLabel.snp.makeConstraints({ (make) in
                    make.left.equalTo(0)
                    make.right.equalTo(0)
                    make.bottom.equalTo(0)
                    make.height.equalTo(0.5)
                })
                
                break
            case .rightAllStyle:
                self.contentView.addSubview(self.leftLabel)
                self.contentView.addSubview(self.icon_right)
                self.contentView.addSubview(self.rightLabel)
                self.contentView.addSubview(self.showDowLabel)

                self.leftLabel.snp.makeConstraints({ (make) in
                    make.left.equalTo(16)
                    make.top.equalTo(17.5)
                    make.height.equalTo(15)
                    make.width.equalTo(k_Wide-100)
                })
                self.icon_right.snp.makeConstraints({ (make) in
                    make.right.equalTo(-16)
                    make.width.equalTo(8.5)
                    make.height.equalTo(13.5)
                    make.top.equalTo((50-13.5)/2)
                })
                self.rightLabel.snp.makeConstraints({ (make) in
                    make.left.equalTo(self.leftLabel.snp.right).offset(0)
                    make.right.equalTo(self.icon_right.snp.left).offset(0)
                    make.top.equalTo(17.5)
                    make.height.equalTo(15)
                })
                self.showDowLabel.snp.makeConstraints({ (make) in
                    make.left.equalTo(0)
                    make.right.equalTo(0)
                    make.bottom.equalTo(0)
                    make.height.equalTo(0.5)
                })
                break
            default:
                break
            }
        }
    }
    var leftLabel:UILabel = UILabel.init()
    var showDowLabel:UILabel = UILabel.init()
    var rightLabel:UILabel = UILabel.init()
    var icon_right:UIImageView = UIImageView.init(image: UIImage.init(named: "icon-detail"))
    var switchButton:UISwitch = UISwitch.init()
    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
//    init(style:UITableViewCellStyle,reuserIdentify:String?,cellStyle:MineSetStyle) {
//        super.init(style: style, reuseIdentifier: reuserIdentify)
//        self.cellStyle = cellStyle
//        self.setUI(style: cellStyle)
//    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setUI()
    }
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
    }
}
extension MineSetSwitchCell{
    func setUI(){
        self.showDowLabel.backgroundColor = .lightGray
        self.rightLabel.textColor = BaseFontColor
        self.leftLabel.font = UIFont.systemFont(ofSize: 15)
        self.rightLabel.font = UIFont.systemFont(ofSize: 15)
        self.rightLabel.textAlignment = .right
//        switch style {
//        case .switchButtonStyle:
//           
//            break
//        case .noRightIconStyle:
//   
//            break
//        case .rightAllStyle:
//           
//            break
//        default:
//            break
//        }
    }
}
